/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.menosehmais.controller;


import br.com.caelum.vraptor.Path;
import br.com.caelum.vraptor.Resource;
import br.com.caelum.vraptor.Result;
import br.com.menosehmais.framework.security.annotation.PermitAll;
import br.com.menosehmais.framework.util.MobileUtils;
import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author Rafael Quintino
 */
@Resource
public class HomeController {
  
    private Result result;
    private HttpServletRequest request;
    
    public HomeController(Result result, HttpServletRequest request){
        this.result = result;
        this.request = request;
    }
    
    @Path("/")
    @PermitAll
    public void index(){
        
        if(MobileUtils.isSmartPhone(request)) {
            result.redirectTo(SmartPhoneController.class).index();
        } else if(MobileUtils.isTablet(request)) {
            result.redirectTo(TabletController.class).index();
        }
        
    }
    
    @Path("/principal")
    public void principal(){
        
        if(MobileUtils.isSmartPhone(request)) {
            result.redirectTo(SmartPhoneController.class).principal();
        } else if(MobileUtils.isTablet(request)) {
            result.redirectTo(TabletController.class).principal();
        }
        
    }
}
